/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* 标题栏 */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    color: #2c3e50;
    font-size: 1.8rem;
    font-weight: 600;
}

.nav-menu {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-link {
    text-decoration: none;
    color: #7f8c8d;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.nav-link:hover,
.nav-link.active {
    color: #3498db;
    background: rgba(52, 152, 219, 0.1);
}

/* 导航按钮 */
.nav-button {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.3s ease;
}

.nav-button:hover {
    background: #2980b9;
}

#registerButton {
    background: #27ae60;
}

#registerButton:hover {
    background: #229954;
}

/* 用户信息显示 */
.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 500;
    color: #2c3e50;
}

.logout-button {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.3s ease;
}

.logout-button:hover {
    background: #c0392b;
}

/* 主要内容区域 */
.main-content {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 1fr; /* 调整为单列布局 */
    gap: 2rem;
    min-height: 70vh;
}

/* 聊天和历史记录包装器 */
.chat-and-history-wrapper {
    display: grid;
    grid-template-columns: 1fr 3fr; /* 历史记录面板与聊天区域的比例为1:3 */
    gap: 2rem;
    min-height: 70vh;
}

/* 历史记录面板 */
.history-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* 历史记录控制按钮容器 */
.history-controls {
    display: flex;
    gap: 0.5rem;
}

/* 新建对话按钮 */
.new-conversation-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.3s ease;
}

.history-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-header h3 {
    font-size: 1.2rem;
    font-weight: 500;
}

.new-conversation-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.clear-history-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.3s ease;
}

.clear-history-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.history-list {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: #f8f9fa;
}

.history-item {
    background: white;
    padding: 0.8rem 1rem;
    margin-bottom: 0.8rem;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    position: relative;
}

.history-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border-left: 3px solid #667eea;
}

.history-item.selected {
    border-left: 3px solid #667eea;
    background: rgba(102, 126, 234, 0.05);
}

/* 删除对话按钮 */
.delete-conversation-btn {
    position: absolute;
    right: 0.5rem;
    top: 0.5rem;
    background-color: transparent;
    border: none;
    color: #ff5252;
    font-size: 1.2rem;
    cursor: pointer;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.3s ease;
}

.history-item:hover .delete-conversation-btn {
    opacity: 1;
}

.delete-conversation-btn:hover {
    background-color: rgba(255, 82, 82, 0.1);
    transform: scale(1.1);
}

.history-item-content {
    font-size: 0.9rem;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-time {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-top: 0.3rem;
}

.no-history {
    text-align: center;
    color: #7f8c8d;
    padding: 2rem;
    font-style: italic;
}

/* 聊天区域 */
.chat-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%; /* 确保聊天区域占满父容器高度 */
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    text-align: center;
    flex-shrink: 0; /* 防止头部被压缩 */
}

.chat-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.chat-container {
    flex: 1; /* 让聊天容器占据剩余空间 */
    display: flex;
    flex-direction: column;
    min-height: 0; /* 允许内容在flex容器中缩小 */
}

/* 未登录提示 */
.not-logged-in {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
}

.login-prompt {
    text-align: center;
    padding: 2rem;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.login-prompt p {
    margin-bottom: 1.5rem;
    color: #7f8c8d;
    font-size: 1.1rem;
}

.prompt-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.primary-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    transition: transform 0.2s ease;
}

.primary-button:hover {
    transform: translateY(-2px);
}

.secondary-button {
    background: white;
    color: #3498db;
    border: 2px solid #3498db;
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.secondary-button:hover {
    background: #3498db;
    color: white;
}

/* 聊天界面 */
.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: #f8f9fa;
    margin-bottom: 1rem;
    max-height: calc(100vh - 300px);
}

.message {
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.user-message {
    flex-direction: row-reverse;
}

.message-content {
    background: white;
    padding: 1rem;
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 80%;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ai-message .message-content {
    background: white;
    border-left: 4px solid #3498db;
}

.message-content ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}
/* 聊天输入容器 */
.chat-input-container {
    padding: 1.5rem;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    margin-top: auto; /* 确保输入框在聊天容器底部 */
}

#messageInput {
    flex: 1;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 0.8rem;
    resize: none;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

#messageInput:focus {
    outline: none;
    border-color: #3498db;
}

.send-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    transition: transform 0.2s ease;
}

.send-button:hover {
    transform: translateY(-2px);
}

/* 课本区域 */
.textbook-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

.textbook-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.textbook-header h2 {
    color: #2c3e50;
    font-size: 1.3rem;
}

.upload-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
}

.upload-btn:hover {
    background: #229954;
}

/* 表单样式 */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #2c3e50;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
}

/* 错误消息样式 */
.error-message {
    color: #e74c3c;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    min-height: 1.2rem;
}

/* 模态框底部链接 */
.modal-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: #7f8c8d;
}

.link {
    color: #3498db;
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
}

.link:hover {
    text-decoration: underline;
}

.textbook-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.textbook-list::-webkit-scrollbar {
    width: 6px;
}

.textbook-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.textbook-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.textbook-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.textbook-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 12px;
    transition: transform 0.2s ease;
}

.textbook-item:hover {
    transform: translateY(-2px);
}

.textbook-icon {
    font-size: 2rem;
}

.textbook-info {
    flex: 1;
    min-width: 0; /* 允许内容在flex容器中缩小 */
}

.textbook-info h3 {
    font-size: 1rem;
    margin-bottom: 0.3rem;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* 长文本显示省略号 */
}

.textbook-info p {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 0.3rem;
}

.textbook-status {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: #e8f5e8;
    color: #27ae60;
}

.read-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
    flex-shrink: 0; /* 防止按钮被压缩 */
    min-width: 60px; /* 确保按钮有足够的最小宽度 */
}

.textbook-icon {
    font-size: 2rem;
}

.textbook-info {
    flex: 1;
}

.textbook-info h3 {
    font-size: 1rem;
    margin-bottom: 0.3rem;
    color: #2c3e50;
}

.textbook-info p {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 0.3rem;
}

.textbook-status {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: #e8f5e8;
    color: #27ae60;
}

.read-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
}

.read-btn:hover {
    background: #2980b9;
}

.read-btn.disabled {
    background: #bdc3c7;
    cursor: not-allowed;
}

/* 视频区域 */
.video-section {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    color: white;
    font-size: 1.8rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 水平滚动容器 - 增强版 */
.video-container-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
    padding-bottom: 10px;
    white-space: nowrap;
    width: 100%;
}

.video-container-wrapper::-webkit-scrollbar {
    height: 8px;
}

.video-container-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.video-container-wrapper::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.video-container-wrapper::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 视频网格 - 增强版 */
.video-grid {
    display: inline-flex;
    gap: 2rem;
    padding: 0;
    margin: 0;
}

.video-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.video-card:hover {
    transform: translateY(-5px);
}

.video-thumbnail {
    height: 180px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.play-icon {
    font-size: 3rem;
    color: white;
    opacity: 0.8;
}

.video-info {
    padding: 1.5rem;
}

.video-info h3 {
    color: #2c3e50;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.video-info p {
    color: #7f8c8d;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.video-status {
    font-size: 0.8rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: #e8f5e8;
    color: #27ae60;
}

.watch-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1rem;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s ease;
}

.watch-btn:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}



/* 模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 2rem;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.close {
    position: absolute;
    right: 1.5rem;
    top: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: #7f8c8d;
}

.close:hover {
    color: #2c3e50;
}

.file-input-container {
    margin: 1.5rem 0;
}

#fileInput {
    display: none;
}

.file-label {
    display: block;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.file-label:hover {
    border-color: #3498db;
}

.file-info {
    margin: 1rem 0;
    padding: 1rem;
    background: #e8f5e8;
    border-radius: 8px;
    display: none;
}

.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    font-size: 1rem;
    transition: transform 0.2s ease;
}

.submit-btn:hover {
    transform: translateY(-2px);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 1rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .nav-menu {
        gap: 1rem;
    }
    
    .video-grid {
        grid-template-columns: 1fr;
    }
    

}
